package com.cty.config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@ComponentScan("com.cty.json")
@EnableWebMvc
public class MvcConfig implements WebMvcConfigurer {//这个接口有很多的springMvc对应的解决方法

    //这个是实现返回模板的全限定符，在handler中返回一个字符串拼接成全限定符，返回其模板
    @Override
    public void configureViewResolvers(ViewResolverRegistry registry) {
        registry.jsp("/WEB-INF/jsp/",".jsp");
    }

    //开启静态资源的访问：先访问->handlerMapping->handlerAdapter->访问静态资源
    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }
}
